package com.example.administrator.yunniuusedcar.holder;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.administrator.common.ui.BaseAdapterRV;
import com.example.administrator.common.ui.BaseHolderRV;
import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.activity.CommodityDetailsActivity;
import com.example.administrator.yunniuusedcar.activity.ShopInfoImagerActivity;
import com.example.administrator.yunniuusedcar.model.mode_benn.RanCarXiangQingBean;
import com.squareup.picasso.Picasso;
public class ShopJiBenXQHolder extends BaseHolderRV<RanCarXiangQingBean> {

    private ImageView JiBenCarPager;
    private TextView tvNumPager;
    private TextView tvSelectdeCarInfo;
    private TextView tvCarYuan;
    private TextView JiFenJia;
    private TextView HuiYuanJia;
    private TextView tvShiChangJia;
    private RadioGroup radio;
    private RadioButton RB2017Kuan;
    private RadioButton RB2018Kuan;
    private FrameLayout flKuanShiXianQing;

    /**
     *   商品详情 基本信息   Created by Administrator on 2017/12/28.
     * @param context 上下文对象
     * @param parent  指RecyclerView控件
     * @param adapter 适配器
     *  1@param layoutResId RecyclerView的一个item布局文件
     */
    public ShopJiBenXQHolder(Context context, ViewGroup parent, BaseAdapterRV<RanCarXiangQingBean> adapter) {
        super(context, parent, adapter, R.layout.fragment_jiben_info);
    }

    @Override
    public void onFindViews(View itemView) {
        intFID();
    }

    @Override
    protected void onRefreshView(RanCarXiangQingBean bean, int position) {
        Picasso.with(context).load(bean.data.list.logo).into(JiBenCarPager);
        tvNumPager.setText(bean.data.list.num+ "张");
        tvSelectdeCarInfo.setText(bean.data.list.name);  //车名
        JiFenJia.setText("积分优惠价格:￥"+ bean.data.list.integral_range);
        HuiYuanJia.setText("会员优惠价格:￥"+bean.data.list.member_range);
        tvShiChangJia.setText("市场价格:￥"+ bean.data.list.market_price);


    }

    private void intFID() {
        JiBenCarPager = (ImageView) itemView.findViewById(R.id.JiBenCarPager);
        tvNumPager = (TextView)  itemView.findViewById(R.id.tv_NumPager);
        tvSelectdeCarInfo = (TextView)  itemView.findViewById(R.id.tv_car_name);
        tvCarYuan = (TextView)  itemView.findViewById(R.id.tv_CarYuan);
        JiFenJia = (TextView)  itemView.findViewById(R.id.JiFenJia);
        HuiYuanJia = (TextView)  itemView.findViewById(R.id.HuiYuanJia);
        tvShiChangJia = (TextView)  itemView.findViewById(R.id.tv_ShiChangJia);

        JiBenCarPager.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CommodityDetailsActivity.mactvity2,ShopInfoImagerActivity.class);
//                startActivity(intent);
            }
        });
    }

    @Override
    protected void onItemClick(View itemView, int position, RanCarXiangQingBean bean) {
        super.onItemClick(itemView, position, bean);

        Intent integer = new Intent(context,ShopInfoImagerActivity.class);
        integer.putExtra("img",bean.data.list.logo);
        integer.putExtra("RanCarid",bean.data.list.car_id);
        context.startActivity(integer);
    }
}
